// @APIVersion 1.0.0
// @Title beego 博客前台 API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers

import (
	"blogs/controllers"
	"blogs/controllers/admin"
	"blogs/middleware"
	beego "github.com/beego/beego/v2/server/web"
)

func init() {
	// 博客前端api
	ns := beego.NewNamespace("/v1",
		// 轮播图管理
		beego.NSNamespace("/focus",
			beego.NSInclude(
				&controllers.FocusController{},
			),
		),
		// 文章管理
		beego.NSNamespace("/article",
			beego.NSInclude(
				&controllers.ArticleController{},
			),
		),
		// 系统管理
		beego.NSNamespace("/setting",
			beego.NSInclude(
				&controllers.SettingController{},
			),
		),
		// tag管理
		beego.NSNamespace("/tag",
			beego.NSInclude(
				&controllers.TagController{},
			),
		),
		// 导航管理
		beego.NSNamespace("/nav",
			beego.NSInclude(
				&controllers.NavController{},
			),
		),
	)

	// 博客后台api
	var nsAdmin = beego.NewNamespace("/v1/admin",
		//中间件:匹配路由前会执,可以用于权限验证
		beego.NSBefore(middleware.AdminAuth),
		//中间件:匹配路由前会执,可以用于权限验证
		// 轮播图管理
		beego.NSNamespace("/focus",
			beego.NSInclude(
				&admin.FocusController{},
			),
		),
		// 图片上传统一接口
		beego.NSNamespace("/imgUpload",
			beego.NSInclude(
				&admin.ImgUploadController{},
			),
		),
		// 文章管理
		beego.NSNamespace("/article",
			beego.NSInclude(
				&admin.ArticleController{},
			),
		),
		// tag管理
		beego.NSNamespace("/tag",
			beego.NSInclude(
				&admin.TagController{},
			),
		),
		// 导航管理
		beego.NSNamespace("/nav",
			beego.NSInclude(
				&admin.NavController{},
			),
		),
		// 用户管理
		beego.NSNamespace("/user",
			beego.NSInclude(
				&admin.NavController{},
			),
		),
		// 登录
		beego.NSNamespace("/login",
			beego.NSInclude(
				&admin.LoginController{},
			),
		),
		//// 系统管理
		//beego.NSNamespace("/setting",
		//	beego.NSInclude(
		//		&admin.SettingController{},
		//	),
		//),

	)
	beego.AddNamespace(ns, nsAdmin)
}
